<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>订单视图页</title>
		<script src="/js/vue.js"></script>
		<script src="/js/axios.js"></script>
		<script src="/js/qs.js"></script>
		<script src="/js/jquery.min.js"></script>
		<script src="//unpkg.com/element-ui@2.4.11/lib/index.js"></script>
		<style scoped>
			/* 在此定义当前页面css */
			@import url("//unpkg.com/element-ui@2.4.11/lib/theme-chalk/index.css");
		</style>

		<style type="text/css">
			#app {
				/* border:1px #dee1eb solid; */
			}

			#max {

				margin: 0 auto;
				margin-top: 40px;
				margin-bottom: 40px;
				width: 95%;
				background-color: white;
			}

			#max1 {

				margin: 0 auto;
				margin-bottom: 40px;
				width: 95%;

			}

			.table1 {
				margin: 0 auto;
				width: 80%;
			}

			.table1 tr {
				height: 40px;

			}

			.td1 {
				width: 10%;
				font-size: 12px;
				/* border-bottom:1px solid black; */
				/* border: 1px #e5e5e5 solid; */
				/* background-color: #F9F9F9; */
			}

			.td2 {
				font-size: 12px;
				text-align: left;
				width: 40%;
			}

			.el-table__header th,
			.el-table__header tr {
				background-color: #dee1e6;
				color: black;
				font-size: 12px;
				line-height: 20px;
			}

			#appreturnleft {
				background-color: white;
				border: 1px #dee1eb solid;
			}

			#appreturnright {
				background-color: white;
				border: 1px #dee1eb solid;
			}
		</style>
	</head>
	<body style="background-color: #f4f8fb;">
		<div id="max">
			<div id="apphard" style="overflow:hidden ;border-radius: 3%;">
				<span style="font-size: 18px; margin-left:  10px; line-height: 60px;">订单</span>
				<!-- <el-button plain @click="printOrder" style="float:right ;margin: 0; margin-right: 2%;
				margin-top: 1%;">打印页面</el-button> -->
				<el-button plain @click="updateOrder" style="float:right ;margin: 0; margin-right: 2%;
			margin-top: 1%;"  v-if="(${orderView.approve}==0 || ${user.uDept}==14) && ${orderView.approve}!=1 ">编辑订单</el-button>
			<el-button plain @click="dialogApproveadmin =true" style="float:right ;margin: 0; margin-right: 2%;
				margin-top: 1%;"  v-if="${user.uDept}==14 && ${orderView.approve}==2">订单审批</el-button>
			<el-button plain @click="dialogApprove=true" style="float:right ;margin: 0; margin-right: 2%;
					margin-top: 1%;"  v-if="${orderView.approve}==0">提交至管理员审批</el-button>
					<el-dialog title="新建订单明细" :visible.sync="dialogOrderItem" width="30%">
						<div style="text-align: center;">
							<span style="font-weight:600;font-family:SimHei;font-size: 18px;">当前订单无订单明细</span><br /><br />
							<el-button type="info" @click="showorderitem">点击新建订单明细</el-button>
						</div>
					</el-dialog>
			<el-dialog title="审批" :visible.sync="dialogApprove" width="30%" append-to-body>
				<span>确定要提交管理员审批</span>
					<span slot="footer" class="dialog-footer">
					<el-button @click="dialogDelete = false">取 消</el-button>
					<el-button type="primary" @click="approve()">确 定</el-button>
				</span>
			</el-dialog>
			<el-dialog title="审批" :visible.sync="dialogApproveadmin" width="30%" append-to-body>
					<div style="width: 160px; margin: 0 auto;">
						<template>
							<el-radio v-model="approvetype" :label="1">通过</el-radio>
							<el-radio v-model="approvetype" :label="3">不通过</el-radio>
						</template>
					</div>
					<span slot="footer" class="dialog-footer">
					<el-button @click="dialogDelete = false">取 消</el-button>
					<el-button type="primary" @click="approveadmin()" >确 定</el-button>
			</el-dialog>
				<el-dialog title="编辑订单" width="60%" :visible.sync="dialogFormVisible">
					<el-form :rules="rules" ref="form" style="font-size: 12px;" :model="form">
						<el-row :gutter="20">
							<el-col :span="12">
								<el-form-item label="主题:" required prop="otitle" :label-width="formLabelWidth">
									<el-input v-model="form.otitle" style="width: 400px;"></el-input>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="20">
							<el-col :span="12">
								<el-form-item label="对应客户:" required prop="customer" :label-width="formLabelWidth">
									<el-select v-model="form.customer" @clear="cumitemvto()" clearable filterable="" remote="" reserve-keyword
									 placeholder="请输入关键词" :remote-method="cumremoteMethod" :loading="cumloading">
										<i slot="prefix" class="el-input__icon el-icon-search"></i>
										<el-option v-for="item in cumitemv" :key="item.value" :label="item.label" :value="item.value">
										</el-option>
									</el-select>
							</el-col>
						</el-row>
						<el-row :gutter="20">
							<el-col :span="12">
								<el-form-item label="订单号:" :label-width="formLabelWidth">
									<div style="font-size: 12px; margin-left: 8%;">{{form.orderId}}</div>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="分类:" :label-width="formLabelWidth">
									<el-select v-model="form.otype" placeholder="请选择">
										<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
										</el-option>
									</el-select>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="20">
							<el-col :span="12">
								<el-form-item label="付款方式:" :label-width="formLabelWidth">
									<el-select v-model="form.orderpay" placeholder="请选择">
										<el-option v-for="item in optionspay" :key="item.value" :label="item.label" :value="item.value">
										</el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="创建时间:" :label-width="formLabelWidth">
									<div style="font-size: 12px; margin-left: 8%;">{{form.date1}}</div>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="20">
							<el-col :span="12">
								<el-form-item label="总金额:" :label-width="formLabelWidth">
									<div style="font-size: 12px; margin-left: 8%;">{{form.fire}} 元</div>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="最晚发货:" required prop="date2" :label-width="formLabelWidth">
									<el-date-picker v-model="form.date2" align="right" type="date" value-format="yyyy-MM-dd" placeholder="选择日期">
									</el-date-picker>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="20">
							<el-col :span="12">
								<el-form-item label="回款金额:" disabled :label-width="formLabelWidth">
									<div style="font-size: 12px; margin-left: 8%;">{{form.get}}元</div>
							</el-col>
							<el-col :span="12">

							</el-col>
						</el-row>
						<el-row :gutter="20">
							<el-col :span="12">
								<el-form-item label="状态:" prop="radiosatus" :label-width="formLabelWidth" required>
									<template>
										<el-radio v-model="form.radiosatus" label="1098">通过</el-radio>
										<el-radio v-model="form.radiosatus" label="1099">不通过</el-radio>
										<el-radio v-model="form.radiosatus" label="1100">意外终止</el-radio>
									</template>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="发货:" :label-width="formLabelWidth">
									<div style="font-size: 12px; margin-left: 8%;">{{form.finput}}</div>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="20">
							<el-col :span="12">
								<!-- prop="uosign" -->
								<el-form-item label="客户签约人:" :label-width="formLabelWidth" required>
									<el-select v-model="form.osign" @clear="uosignto()" clearable filterable="" remote="" reserve-keyword
									 placeholder="请输入关键词" :remote-method="osignremoteMethod" :loading="osignloading">
										<i slot="prefix" class="el-input__icon el-icon-search"></i>
										<el-option v-for="item in uosign" :key="item.value" :label="item.label" :value="item.value">
										</el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="退货:" :label-width="formLabelWidth">
									<div style="font-size: 12px; margin-left: 8%;">{{form.tinput}}</div>
								</el-form-item>
							</el-col>
						</el-row>
						<el-row :gutter="20">
							<el-col :span="12">
								<!-- prop="uitemv" -->
								<el-form-item label="所有者:" :label-width="formLabelWidth" required>
									<el-select v-model="form.uid" @clear="uitemvto()" clearable filterable="" remote="" reserve-keyword
									 placeholder="请输入关键词" :remote-method="uidremoteMethod" :loading="uidloading">
										<i slot="prefix" class="el-input__icon el-icon-search"></i>
										<el-option v-for="item in uitemv" :key="item.value" :label="item.label" :value="item.value">
										</el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="12">

							</el-col>
						</el-row>
						<el-form-item label="备注:" :label-width="formLabelWidth">
							<el-input type="textarea" :rows="12" :autosize="{ minRows: 4 }" placeholder="" v-model="form.textcommunication"
							 style="width: 80%;"></el-input>
						</el-form-item>
						<hr style="border: 0.5px solid #EEEEEE;" />
						<el-row :gutter="20">
							<el-form-item label="收货人/地址:" :label-width="formLabelWidth">
								<el-collapse v-model="activeNames" @change="handleChange">
									<el-collapse-item style="color: #0030CE;" title="点击展开" name="1">
										<span style="color: #333333;font-weight: 700;">收货人:</span>
										<hr style="border: 0.5px solid #EEEEEE;" />
										<el-row :gutter="20">
											<el-col :span="12">
												<el-form-item label="从联系人读取:" prop="custID" :label-width="formLabelWidth">
													<el-select @change="aa()" @clear="uosign1to()" v-model="form.osign1" clearable filterable="" remote=""
													 reserve-keyword placeholder="请输入关键词" :remote-method="osignremoteMethod1" :loading="osignloading1">
														<i slot="prefix" class="el-input__icon el-icon-search"></i>
														<el-option v-for="item in uosign1" :key="item.value" :label="item.label" :value="item.value"> <i slot="prefix"
															 class="el-input__icon el-icon-search"></i>
														</el-option>
													</el-select>
												</el-form-item>
											</el-col>
										</el-row>
										<el-row :gutter="30" style="margin-top: 20px;">
											<el-col :span="12">
												<el-form-item label="或者填写姓名:" prop="custID" :label-width="formLabelWidth">
													<el-input v-model="form.oconsignee"></el-input>
												</el-form-item>
											</el-col>
										</el-row>
										<el-row :gutter="30" style="margin-top: 20px;">
											<el-col :span="12">
												<el-form-item label="电话:" prop="custID" :label-width="formLabelWidth">
													<el-input v-model="form.conphone"></el-input>
												</el-form-item>
											</el-col>
										</el-row>
										<span style="color: #333333;font-weight: 700;">收货地址:</span>
										<hr style="border: 0.5px solid #EEEEEE;" />
										<el-row :gutter="30" style="margin-top: 20px;">
											<el-col :span="24">
												<el-form-item label="地址:" prop="custID" :label-width="formLabelWidth">
													<el-input v-model="form.contaddress" style="width: 80%;"></el-input>
												</el-form-item>
											</el-col>
										</el-row>
										<el-row :gutter="30" style="margin-top: 20px;">
											<el-col :span="12">
												<el-form-item label="邮编:" prop="custID" :label-width="formLabelWidth">
													<el-input v-model="form.postcode"></el-input>
												</el-form-item>
											</el-col>
										</el-row>
									</el-collapse-item>
								</el-collapse>
							</el-form-item>
							</el-col>
						</el-row>
					</el-form>
					<div slot="footer" class="dialog-footer">
						<el-button @click="dialogFormVisible = false">取 消</el-button>
						<!-- dialogFormVisible = false -->
						<el-button type="primary" @click="submitFormUp('form')">保存</el-button>
					</div>
				</el-dialog>

			</div>
			<hr />
			<div id="app">
				<table class="table1">
					<tr align="right">
						<td class="td1">主题：</td>
						<td class="td2">${orderView.theme}</td>
						<td></td>
						<td></td>
					</tr>
					<tr align="right">
						<td class="td1">对应客户：</td>
						<td class="td2">${orderView.customer} </td>
						<td></td>
						<td></td>
					</tr>
					<tr align="right">
						<td class="td1">订单号：</td>
						<td class="td2">${orderView.ID}</td>
						<td class="td1">分类：</td>
						<td class="td2">${orderView.type}</td>
					</tr>
					<tr align="right">
						<td class="td1">付款方式：</td>
						<td class="td2">${orderView.pay}</td>
						<td class="td1">对应机会：</td>
						<td></td>
					</tr>
					<tr align="right">
						<td class="td1">总金额：</td>
						<td class="td2">${orderView.fire}元</td>
						<td></td>
						<td></td>
					</tr>
					<tr align="right">
						<td class="td1">发货金额：</td>
						<td></td>
						<td class="td1">回款金额：</td>
						<td class="td2">${orderView.get}元</td>
					</tr>
					<tr align="right">
						<td class="td1">创建日期：</td>
						<td class="td2">${orderView.statretime}</td>
						<td class="td1">最晚发货：</td>
						<td class="td2">${orderView.o_fadate}</td>
					</tr>
					<tr align="right">
						<td class="td1">客户签约人：</td>
						<td class="td2">${orderView.o_sign}</td>
						<td class="td1">发货：</td>
						<td class="td2">${orderView.fstutes}</td>
					</tr>
					<tr align="right">
						<td class="td1">所有者：</td>
						<td class="td2">${orderView.uname}</td>
						<td class="td1">退货：</td>
						<td class="td2">${orderView.salesreturn}</td>
					</tr>
					<tr align="right">
						<td class="td1">状态：</td>
						<td class="td2">${orderView.dstatus}</td>
						<td class="td1">审批状态:</td>
						<td class="td2">
							<span style="color: red;" v-if="${orderView.approve}==0">
								未审批
							</span>
							<span style="color: red;" v-if="${orderView.approve}==1">
								已审批
							</span>
							<span style="color: red;" v-if="${orderView.approve}==2">
								待审批
							</span>
							<span style="color: red;" v-if="${orderView.approve}==3">
								审批未通过
							</span>
						</td>
					</tr>
					<tr align="center">
						<td class="td1" colspan="4"><span style="font-weight:bold;font-size: 13px;">自定义信息</span></td>
					</tr>
					<tr align="right">
						<td class="td1">订单明细：</td>
						<td></td>
						<td></td>
						<td></td>
					</tr>
					<tr align="center">
						<td class="td1" colspan="4">
							<div id="spendiv" style="width: 90%; text-align: right;">
								<div style="margin-right: 2%;margin-bottom: 1%;"  v-if="${orderView.approve}==0">
									<el-button size="mini" @click="showorderitem">点击编辑订单明细</el-button>
								</div>
								<div>
									<template>
										<el-table :data="tableData" border :summary-method="getSummaries" show-summary>
											<el-table-column prop="p_name" label="产品名" align="center">
											</el-table-column>
											<el-table-column prop="technology" label="型号" align="center">
											</el-table-column>
											<el-table-column prop="count" label="数量" align="center">
											</el-table-column>
											<el-table-column prop="p_unit" label="单位" align="center">
											</el-table-column>
											<el-table-column prop="price" label="单价" align="center">
											</el-table-column>
											<el-table-column prop="discount" label="折扣" align="center">
											</el-table-column>
											<el-table-column prop="money" label="金额" align="center">
											</el-table-column>
											<el-table-column prop="remark" show-overflow-tooltip label="备注" align="center">
											</el-table-column>
										</el-table>
									</template>
						</td>
					</tr>
					<tr align="right">
						<td class="td1">备注：</td>
						<td class="td2" colspan="2">${orderView.oremark}</td>
					</tr>
					<tr align="right">
						<td class="td1">收货人/地址：</td>
						<td></td>
						<td></td>
						<td></td>
					</tr>
					<tr align="right">
						<td class="td1"></td>
						<td class="td2" colspan="3">
							<el-collapse v-model="activeNames" @change="handleChange">
								<el-collapse-item title="详细信息:" name="1">
									<el-row :gutter="10">
										<el-col :span="4">
											<div style="color: #333333;font-weight: 700; ">收货人</div>
										</el-col>

										<el-col :span="24"></el-col>
									</el-row>
									<el-row :gutter="10">
										<el-col :span="4">
											<div> &nbsp;</div>
										</el-col>
										<el-col :span="16">姓名：${orderView.oconsignee}</el-col>
									</el-row>
									<el-row :gutter="10">
										<el-col :span="4">
											<div>&nbsp; </div>
										</el-col>
										<el-col :span="16">电话：${orderView.oconphone}</el-col>
									</el-row>
									<el-row :gutter="10">
										<el-col :span="4">
											<div style="color: #333333;font-weight: 700;">地址</div>
										</el-col>
										<el-col :span="24"></el-col>
									</el-row>
									<el-row :gutter="10">
										<el-col :span="4">
											<div> &nbsp;</div>
										</el-col>
										<el-col :span="16">地址：${orderView.oaddress}</el-col>
									</el-row>
									<el-row :gutter="10">
										<el-col :span="4">
											<div>&nbsp; </div>
										</el-col>
										<el-col :span="16">邮编：${orderView.opostcode}</el-col>
									</el-row>
								</el-collapse-item>
							</el-collapse>
						</td>
					</tr>
				</table>
			</div>
		</div>
		</div>
		</div>
		<div id="max2" style="border-radius: 5px; background-color: white; margin: 0 auto;  margin-bottom: 20px; width: 95%;" v-if="${orderView.approve}==1">
			<span style="font-size: 12px; margin-left: 20px; font-weight: 800;"> <i class="el-icon-caret-right" style="font-size: 14px;"></i>订单已交付明细/发货单</span><br />
			<div style="margin: 0 auto; margin-top: 20px; width: 145px;" v-if="stockremoval">
				<el-button @click="adddispatchBill" type="primary" size="medium">生成发货单</el-button>
			</div>
			<div style="margin: 0 auto; margin-top: 20px;" v-if="outgoodgo">
				<div style="margin: 0 auto; width: 80px; margin-top: -15px; font-weight: 600;">发货单</div>
				<el-form ref="repform" label-width="100px" class="demo-repform" style="width: 90%;margin-left:4%;">
					<el-row :gutter="10">
						<el-col :span="7" style="margin-left:50px;">
							<el-form-item label="发货号:" label-width="80px" style=" font-size: 3px; font-weight: 500;font-family: SimHei;">
								${outgood.ogId}
							</el-form-item>
						</el-col>
						<el-col :span="7" style="margin-left:40px;">
							<el-form-item label="日期:" label-width="80px" style=" font-size: 3px;font-weight: 500;font-family: SimHei;">
							${outgood.deliverydate}
							</el-form-item>
						</el-col>
						<el-col :span="7" style="margin-left:40px;">
							<el-form-item label="状态:" label-width="80px" style="font-size: 3px;font-weight: 500;font-family: SimHei;">
								<span style="color: red; font-weight: 600;" v-if="'${outgood.ogType}'=='0'">
									未发货
								</span>
								<span style="color: red; font-weight: 600;" v-if="'${outgood.ogType}'=='1'">
									已发货
								</span>
							</el-form-item>
						</el-col>
					</el-row>
					<el-row :gutter="10">
						<el-col :span="7" style="margin-left:50px;">
							<el-form-item label="收货人:" label-width="80px" style=" font-size: 3px;margin-top: -30px;font-weight: 500;font-family: SimHei;">
								${outgood.shoumen}
							</el-form-item>
						</el-col>
						<el-col :span="7" style="margin-left:40px;">
							<el-form-item label="发货人:" label-width="80px" style="  font-size: 3px; margin-top: -30px;font-weight: 500;font-family: SimHei;">
								${outgood.u_name}
							</el-form-item>
						</el-col>
						<el-col :span="7" style="margin-left:40px;">
							<el-form-item label="发货方式:" label-width="80px" style=" font-size: 3px;margin-top: -30px;font-weight: 500;font-family: SimHei;">
								${outgood.deliverymethod}
							</el-form-item>
						</el-col>
					</el-row>
					<div style="width: 120px; float: right; margin-top: -20px;  margin-right: 30px; margin-bottom: 5px;">
						<el-button @click="outgoodview" type="primary" plain size="mini" v-if="outgoodgo">查看发货单</el-button>
					</div>
					<div style="width: 90px; float: right; margin-top: -20px; margin-bottom: 5px;">
						<el-button @click="returngoodview" type="primary" plain size="mini" v-if="'${outgood.ogType}'=='1'">办理退货</el-button>
					</div>
					<div style="margin: 0 auto; width:90%; ">
						<template>
							<el-table :data="tableData" border style="margin: 0 auto; border-radius: 10px; " :summary-method="getSummaries"
							 show-summary>
								<el-table-column prop="p_name" label="产品名" align="center">
								</el-table-column>
								<el-table-column prop="p_name" label="型号" align="center">
								</el-table-column>
								<el-table-column prop="odCount" label="数量" align="center">
								</el-table-column>
								<el-table-column prop="p_unit" label="单位" align="center">
								</el-table-column>
								<el-table-column prop="odPrice" label="单价" align="center">
								</el-table-column>
								<el-table-column prop="odDiscount" label="折扣" align="center">
								</el-table-column>
								<el-table-column prop="odMoney" label="金额" align="center">
								</el-table-column>
								<el-table-column prop="odRemark" show-overflow-tooltip label="备注" align="center">
								</el-table-column>
							</el-table>
						</template>
					</div>
				</el-form>
			</div>
			<br /><br />
			<el-dialog title="编辑退货单" :visible.sync="dialogoutgood" width="55%" append-to-body>
					<el-form  ref="form" style="font-size: 12px;" :model="form">
						<el-row :gutter="30" style="margin-top: 20px;">
							<el-col :span="12">
								<el-form-item label="产品名:" label-width="80px">
									<el-select v-model="returnPId" @clear="uosignto()" clearable  @change="selectprodut1" filterable="" remote="" reserve-keyword placeholder="请选择退货产品" >
										<i slot="prefix" class="el-input__icon el-icon-search"></i>
										<el-option v-for="item in returngoodpro"    :key="item.value" :label="item.label" :value="item.value"> 
									</el-option>
									</el-select>
								</el-form-item>
							</el-col>
							<el-col :span="12">
								<el-form-item label="退货数量:" label-width="80px">
								<template>
									<el-input-number v-model="returnCount" :controls="false" :min="0" :max="numMax" label="描述文字"></el-input-number>
								</template>
									<!-- <el-input placeholder="" v-model="returnCount" style="width: 90%;"></el-input> -->
								</el-form-item>
							</el-col>
						</el-row>
							<el-form-item label="退货原因:" label-width="80px">
								<el-input type="textarea" :rows="12" :autosize="{ minRows: 3}" placeholder=""  v-model="returnre" style="width: 80%;"></el-input>
							<el-tooltip content="Bottom center" placement="bottom">
								<div slot="content">添加</div>
								<i style="font-size: 20px; cursor: pointer; margin-left: 30px;" @click="returnPush" class="el-icon-plus"></i>
							</el-tooltip>
								
							</el-form-item>
					</el-form>
					<template>
						
						<el-table :data="tableData1" border style="margin: 0 auto; border-radius: 10px; ">
							<el-table-column prop="pName" label="产品名"  width="120px"  align="center">
							</el-table-column>
							<el-table-column prop="riCount" label="数量" width="50px" align="center">
							</el-table-column>
							<el-table-column prop="pUnit" label="单位" width="50px" align="center">
							</el-table-column>
							<el-table-column prop="riPrice" label="单价"  width="100px" align="center">
							</el-table-column>
							<el-table-column prop="odDiscount" label="折扣"  width="50px" align="center">
							</el-table-column>
							<el-table-column prop="riMoney" label="金额"  width="100px" align="center">
							</el-table-column>
							<el-table-column prop="riResult" show-overflow-tooltip label="备注" align="center">
							</el-table-column>
							<el-table-column prop="name" label="操作"  width="50px" align="center">
								<template slot-scope="scope">
									<el-tooltip content="Bottom center" placement="bottom">
										<div slot="content">删除</div>
										<i class="el-icon-delete" style="margin: 0px 10px;font-size: 17px;" @click="deletenew(scope.$index, tableData1)"></i>
									</el-tooltip>
								</template>
							</el-table-column>
						</el-table>
					</template>
					<span slot="footer" class="dialog-footer">
					<el-button @click="dialogoutgood = false">取 消</el-button>
					<el-button type="primary" @click="appreturngood()">生成退货单</el-button>
			</el-dialog>
		</div>
		<div id="max3" >
			<div style="border-radius: 5px; background-color: white; margin: 0 auto;  margin-bottom: 20px; width: 95%;" v-for="item in refunlist1">
			<span style="font-size: 12px; margin-left: 20px; font-weight: 800;"> <i class="el-icon-caret-right" style="font-size: 14px;"></i>退货明细/退货单</span><br />
			
			<div style="margin: 0 auto; margin-top: 20px;" v-if="outgoodgo" >
				
				<div style="margin: 0 auto; width: 80px; margin-top: -15px; font-weight: 600;">退货单</div>
				<el-form ref="repform" label-width="100px" class="demo-repform" style="width: 90%;margin-left:4%;">
					<el-row :gutter="10">
						<el-col :span="7" style="margin-left:50px;">
							<el-form-item label="退货号:" label-width="80px" style=" font-size: 3px; font-weight: 500;font-family: SimHei;">
								{{item.map.rgId}}
							</el-form-item>
						</el-col>
						<el-col :span="7" style="margin-left:40px;">
							<el-form-item label="日期:" label-width="80px" style=" font-size: 3px;font-weight: 500;font-family: SimHei;">
							{{item.map.data}}
							</el-form-item>
						</el-col>
						<el-col :span="7" style="margin-left:40px;">
							<el-form-item label="状态:" label-width="80px" style="font-size: 3px;font-weight: 500;font-family: SimHei;">
								<span style="color: red; font-weight: 600;" v-if="item.map.srefundstatus==1">
									退货中
								</span>
								<span style="color: red; font-weight: 600;" v-if="item.map.srefundstatus==2">
									已完成
								</span>
							</el-form-item>
						</el-col>
					</el-row>
					<div style="width: 120px; float: right; margin-top: -20px;  margin-right: 30px; margin-bottom: 5px;">
						<el-button @click="refundgoods(item.map.rgId)" type="primary" plain size="mini" >查看退货</el-button>
					</div>
					<div style="margin: 0 auto; width:90%;">
						<template>
							<el-table :data="item.listMap" border style="margin: 0 auto; border-radius: 10px; " :summary-method="getSummaries"
							 show-summary>
								<el-table-column prop="p_name" label="产品名" align="center">
								</el-table-column>
								<el-table-column prop="p_name" label="型号" align="center">
								</el-table-column>
								<el-table-column prop="riCount" label="数量" align="center">
								</el-table-column>
								<el-table-column prop="p_unit" label="单位" align="center">
								</el-table-column>
								<el-table-column prop="riPrice" label="单价" align="center">
								</el-table-column>
								<el-table-column prop="riMoney" label="金额" align="center">
								</el-table-column>
								<el-table-column prop="riResult" show-overflow-tooltip label="退货原因" align="center">
								</el-table-column>
							</el-table>
						</template>
					</div>
				</el-form>
				<div style="height: 50px;">
					
				</div>
			</div>
			
		</div>
		</div>
		<div id="max1">
			<div id="appreturn"  v-if="${orderView.approve}==1">
				<el-row>
					<el-col :span="12">
						<div id="appreturnleft" style=" height: 200px; border-radius: 3%; ">
							<el-row :span="6">
								<div style="background-color: #F1F3F4; font-size: 12px;font-weight: bold;height: 30px;">
									<span style="margin-left: 1%; line-height: 30px;">回款计划</span>
									<el-button type="info" style="float: right; margin-right: 2%;" @click="addbmppage()" v-if="addbmpboo" size="mini"
									 plain>新建</el-button>
									<!-- Form -->
									<el-dialog title="回款计划" :visible.sync="dialogFormVisible" width="50%">
										<hr style="border: 0.5px solid #666666;margin: -15px 0px 35px;" />
										<el-form :model="bmpform" :rules="rules" ref="bmpform" label-width="100px" class="demo-bmpform" style="margin-top: 20px;">
											<el-form-item label="对应客户:" required prop="comcustid" :label-width="formLabelWidth">
												<el-select disabled v-model="bmpform.comcustid" @clear="comcustidto()" @change="selectOne()" clearable
												 filterable="" style="width: 60%;" remote="" reserve-keyword placeholder="请输入关键词" :remote-method="cumremoteMethod"
												 :loading="cumloading">
													<i slot="prefix" class="el-input__icon el-icon-search"></i>
													<el-option v-for="item in customer" :key="item.value" :label="item.label" :value="item.value">
													</el-option>
												</el-select>
											</el-form-item>
											<el-form-item label="订单" required prop="orderid" :label-width="formLabelWidth">
												<!-- <el-autocomplete v-model="bmpform.orderid" :fetch-suggestions="querySearchAsync" placeholder="请输入内容" @select="handleSelect"
									 			 style="width: 60%;"></el-autocomplete> -->
												<el-select disabled v-model="bmpform.orderid" clearable filterable="" style="width: 60%;" remote=""
												 reserve-keyword placeholder="请输入关键词" :remote-method="orremoteMethod" :loading="orloading">
													<i slot="prefix" class="el-input__icon el-icon-search"></i>
													<el-option v-for="item in orderes" :key="item.value" :label="item.label" :value="item.value">
													</el-option>
												</el-select>
											</el-form-item>
											<el-row :gutter="20">
												<el-col :span="12">
													<el-form-item label="计划回款日期:" required prop="date1" :label-width="formLabelWidth">
														<el-date-picker v-model="bmpform.date1" type="date" value-format="yyyy-MM-dd" :picker-options="pickerOptions0"
														 placeholder="选择日期">
														</el-date-picker>
													</el-form-item>
												</el-col>
												<el-col :span="12">
													<el-form-item label="金额:" required prop="bmpmoney" :label-width="formLabelWidth">
														<el-input v-model="bmpform.bmpmoney" style="width: 50%;"></el-input>
													</el-form-item>
												</el-col>
											</el-row>
											<el-row :gutter="20">
												<el-col :span="24">
													<el-form-item label="状态:" prop="radiosatus" :label-width="formLabelWidth" required>
														<template>
															<el-radio v-model="bmpform.radiosatus" label="已回">已回</el-radio>
															<el-radio v-model="bmpform.radiosatus" label="未回">未回</el-radio>
															<el-radio v-model="bmpform.radiosatus" label="不提醒">不提醒</el-radio>
														</template>
													</el-form-item>
												</el-col>
											</el-row>
											<el-row :gutter="20">
												<el-col :span="12">
													<!-- prop="uitemv" -->
													<el-form-item label="所有者:" required prop="uid" :label-width="formLabelWidth" required>
														<el-select v-model="bmpform.uid" @clear="uitemvto()" clearable filterable="" remote="" reserve-keyword
														 placeholder="请输入关键词" :remote-method="uidremoteMethod" :loading="uidloading">
															<i slot="prefix" class="el-input__icon el-icon-search"></i>
															<el-option v-for="item in uitemv" :key="item.value" :label="item.label" :value="item.value">
															</el-option>
														</el-select>
													</el-form-item>
												</el-col>
												<el-col :span="12">
												</el-col>
											</el-row>
											<el-form-item label="备注:" :label-width="formLabelWidth">
												<el-input type="textarea" :rows="12" :autosize="{ minRows:4 }" placeholder="" v-model="bmpform.textcommunication"
												 style="width: 80%;"></el-input>
											</el-form-item>
										</el-form>
										<div slot="footer" class="dialog-footer">
											<el-button @click="dialogFormVisible = false">取 消</el-button>
											<!-- dialogFormVisible = false -->
											<el-button type="primary" @click="submitForm('bmpform')">添加</el-button>
										</div>
									</el-dialog>

								</div>
								<div style="font-size: 12px; height: 20px;" v-for="item in bmp">
									<span style="margin-left: 2%; margin-right:2%;underline;cursor:pointer;">
										<i class="el-icon-caret-right"></i>
										￥{{item.bmpmoney}}</span>{{item.bmp_bmpdate1}}
									<span style="margin-left: 2%;" v-if="item.isBackMoney=='未回'">
										<i class="el-icon-more-outline"></i>
										<i class="el-icon-more-outline"></i>
										<a style="color: #0080FF; cursor:pointer;" @click="backmp(item.ID,item.bmp_bmpdate1,item.bmpmoney)">回款</a>
									</span>
									<span style="margin-left: 2%; font-size: 15px;" v-else>
										<el-tooltip content="Bottom center" placement="bottom">
											<div slot="content">已回款</div>
											<i class="el-icon-success"></i>
										</el-tooltip>
									</span>
								</div>
							</el-row>
						</div>
					</el-col>

					<el-col :span="12">
						<div id="appreturnright" style="height: 200px; border-radius: 3%; ">
							<el-row :span="6">
								<div style="background-color: #F1F3F4;font-size: 12px;font-weight: bold;height: 30px;">
									<span style="margin-left: 1%; line-height: 30px;">回款记录</span>
									<!-- <el-button type="info" style="float: right; margin-right: 3%;" @click="addrmpage()" size="mini" plain>新建</el-button> -->
									<el-dialog title="新增回款记录" :visible.sync="rdialogFormVisible" width="55%">
										<hr style="border: 0.5px solid #666666;margin: -15px 0px 35px;" />
										<el-form :model="rmform" :rules="rules" ref="rmform" label-width="100px" class="demo-rmform" style="margin-top: 20px;">
											<el-form-item label="对应客户:" required prop="comcustid" :label-width="formLabelWidth">
												<el-select v-model="rmform.comcustid" disabled @clear="comcustidto()" @change="selectOne()" clearable
												 filterable="" style="width: 60%;" remote="" reserve-keyword placeholder="请输入关键词" :remote-method="cumremoteMethod"
												 :loading="cumloading">
													<i slot="prefix" class="el-input__icon el-icon-search"></i>
													<el-option v-for="item in customer" :key="item.value" :label="item.label" :value="item.value">
													</el-option>
												</el-select>
											</el-form-item>
											<el-form-item label="订单" required prop="orderid" :label-width="formLabelWidth">
												<!-- <el-autocomplete v-model="bmpform.orderid" :fetch-suggestions="querySearchAsync" placeholder="请输入内容" @select="handleSelect"
												 style="width: 60%;"></el-autocomplete> -->
												<el-select v-model="rmform.orderid" disabled clearable filterable="" style="width: 60%;" remote=""
												 reserve-keyword placeholder="请输入关键词" :remote-method="orremoteMethod" :loading="orloading">
													<i slot="prefix" class="el-input__icon el-icon-search"></i>
													<el-option v-for="item in orderes" :key="item.value" :label="item.label" :value="item.value">
													</el-option>
												</el-select>
											</el-form-item>
											<el-row :gutter="20">
												<el-col :span="12">
													<el-form-item label="回款日期:" required prop="date1" :label-width="formLabelWidth">
														<el-date-picker :picker-options="pickerOptions0" v-bind:disabled="disabledInput" v-model="rmform.date1"
														 type="date" value-format="yyyy-MM-dd" placeholder="选择日期">
														</el-date-picker>
													</el-form-item>
												</el-col>
												<el-col :span="12">
													<el-form-item label="金额:" required prop="rmmoney" :label-width="formLabelWidth">
														<el-input v-bind:disabled="disabledInput" v-model="rmform.rmmoney" style="width: 50%;"></el-input>
													</el-form-item>
												</el-col>
											</el-row>
											<el-row :gutter="20">
												<el-col :span="12">
													<el-form-item label="付款方式:" required prop="rmpay" :label-width="formLabelWidth">
														<el-select v-model="rmform.rmpay" placeholder="请选择">
															<el-option v-for="item in optionspay" :key="item.value" :label="item.label" :value="item.value">
															</el-option>
														</el-select>
													</el-form-item>
												</el-col>
												<el-col :span="12">
													<el-form-item label="分类:" required prop="rmsort" :label-width="formLabelWidth">
														<el-select v-model="rmform.rmsort" placeholder="请选择">
															<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
															</el-option>
														</el-select>
													</el-form-item>
												</el-col>
											</el-row>
											<el-row :gutter="20">
												<el-col :span="12">
													<!-- prop="uitemv" -->
													<el-form-item label="所有者:" required prop="uid" :label-width="formLabelWidth" required>
														<el-select v-model="rmform.uid" @clear="uitemvto()" clearable filterable="" remote="" reserve-keyword
														 placeholder="请输入关键词" :remote-method="uidremoteMethod" :loading="uidloading">
															<i slot="prefix" class="el-input__icon el-icon-search"></i>
															<el-option v-for="item in uitemv" :key="item.value" :label="item.label" :value="item.value">
															</el-option>
														</el-select>
													</el-form-item>
												</el-col>
												<el-col :span="12">
												</el-col>
											</el-row>
											<el-form-item label="备注:" :label-width="formLabelWidth">
												<el-input type="textarea" :rows="12" :autosize="{ minRows: 4 }" placeholder="" v-model="rmform.textcommunication"
												 style="width: 80%;"></el-input>
											</el-form-item>
										</el-form>
										<div slot="footer" class="dialog-footer">
											<el-button @click="rdialogFormVisible = false">取 消</el-button>
											<!-- dialogFormVisible = false -->
											<el-button type="primary" @click="rsubmitForm('rmform')">添加</el-button>
										</div>
									</el-dialog>

								</div>
								<div style="font-size: 12px; height: 20px;" v-for="item in rm">
									<span style="margin-left: 2%; margin-right:2%;underline;cursor:pointer;">
										<i class="el-icon-caret-right"></i>
										￥{{item.money}}</span>{{item.rm_date1}}
								</div>
							</el-row>
						</div>
					</el-col>
				</el-row>
				
				<el-dialog title="智能新建回款计划" :visible.sync="dialogbmpviewVisible" width="40%">
					<hr style="border: 0.5px solid #666666;margin: -15px 0px 35px;" />
					<el-form :model="zbmpform" :rules="rules" ref="zbmpform" label-width="100px" class="demo-zbmpform">
						<el-form-item label="对应客户:" required prop="comcustid" :label-width="formLabelWidth1">
							<el-select v-model="zbmpform.comcustid" disabled @clear="comcustidto()" @change="selectOne()" clearable
							 filterable="" style="width: 70%;" remote="" reserve-keyword placeholder="请输入客户" :remote-method="cumremoteMethod"
							 :loading="cumloading">
								<i slot="prefix" class="el-input__icon el-icon-search"></i>
								<el-option v-for="item in customer" :key="item.value" :label="item.label" :value="item.value">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="订单" required prop="orderid" :label-width="formLabelWidth1">
							<el-select v-model="zbmpform.orderid" disabled clearable filterable="" style="width: 70%;" remote=""
							 reserve-keyword placeholder="请选择订单" :remote-method="orremoteMethod" :loading="orloading">
								<i slot="prefix" class="el-input__icon el-icon-search"></i>
								<el-option v-for="item in orderes" :key="item.value" :label="item.label" :value="item.value">
								</el-option>
							</el-select>
						</el-form-item>
						<el-row :gutter="10">
							<!-- prop="uitemv" -->
							<el-form-item label="所有者:" required prop="uid" :label-width="formLabelWidth1" required>
								<el-select v-model="zbmpform.uid" @clear="uitemvto()" clearable filterable="" remote="" reserve-keyword
								 placeholder="请选择所有者" :remote-method="uidremoteMethod" :loading="uidloading">
									<i slot="prefix" class="el-input__icon el-icon-search"></i>
									<el-option v-for="item in uitemv" :key="item.value" :label="item.label" :value="item.value">
									</el-option>
								</el-select>
							</el-form-item>
						</el-row>
						<el-form-item label="备注:" :label-width="formLabelWidth1">
							<el-input type="textarea" :rows="12" :autosize="{ minRows: 2}" placeholder="" v-model="zbmpform.textcommunication"
							 style="width: 80%;"></el-input>
						</el-form-item>
						<div style="font-size: 12px; margin-left: 3px;">
							<hr style="background-color:#f1f3f4;" />
							<span style="color: red;">智能应收提示：</span><br />
							订单金额<span style="color: red;font-size: 13px;">￥${orderView.fire}</span>,已生成回款计划总额<span style="color: red;font-size: 13px;">￥{{bsumMoney}}</span>,未计划回款总额<span
							 style="color: red;font-size: 13px;">￥{{bsumMoney1}}</span><br />
							建议回款金额如下：
							<br />
							<template>
								<el-table :data="ztableData" border>
									<el-table-column type="index" label="编号" width="50px" align="center">
									</el-table-column>
									<el-table-column prop="bmpmoney" width="130px" label="金额" align="center">
										<template slot-scope="{row,$index}">
											￥<el-input v-model="row.bmpmoney" @change="updatebmpmoney(row)" style="width:85%;" placeholder="金额"></el-input>
										</template>
									</el-table-column>
									<el-table-column prop="percent" label="百分比" width="100px" align="center">
										<template slot-scope="{row,$index}">
											<el-input v-model="row.percent" @change="updatepercent(row)" style="width:75%;" placeholder="金额"></el-input>%
										</template>
									</el-table-column>
									<el-table-column prop="date1" label="计划回款日期" align="center">
										<template slot-scope="{row,$index}">
											<el-date-picker type="date" :picker-options="pickerOptions0" placeholder="选择日期" style="width:90%;" v-model="row.date1" value-format="yyyy-MM-dd"></el-date-picker>
										</template>
									</el-table-column>
								</el-table>
							</template>
						</div>

					</el-form>
					<div slot="footer" class="dialog-footer">
						<el-button @click="rdialogFormVisible = false">取 消</el-button>
						<!-- dialogFormVisible = false -->
						<el-button type="primary" @click="addrsubmitForm('zbmpform')">添加</el-button>
					</div>
				</el-dialog>
			</div>

			<!-- Form -->


		</div>





		<script type="text/javascript">
			var bmp = ${
				bmpMap
			};
			var rm = ${
				rmMap
			};
			var oid = ${
				orderView.ID
			};
			var orderitemView = ${
				orderItemView
			};
			var orderinfo = ${
				orderinfo
			};
			var outgooditem = ${
				outgoodItem
			}
			var refunlist=${refunList
			}
			new Vue({
				el: "#app",
				data: {
					orderitem: '',
					formLabelWidth: '100px',
					form: {
						name: '',
						region: '',
						date1: '',
						date2: '',
						delivery: false,
						type: [],
						resource: '',
						desc: '',
						activeNames: ['1']
					},
					tableData: orderitemView,
					zyx: 'zyx1',
					activeNames: ''
				},
				methods: {
					handleChange(val) {
						console.log(val);
					},
					showorderitem() {

						window.location.href = '/sales/prosale/orderItemView?id=' + oid;
					},

					add() {
						console.log();
					},
					onSubmit() {
						console.log('submit!');
					},
					getSummaries(param) {
						const {
							columns,
							data
						} = param;
						const sums = [];
						columns.forEach((column, index) => {
							if (index === 0) {
								sums[index] = '总计';
								return;
							}
							const values = data.map(item => Number(item[column.property]));

							if (!values.every(value => isNaN(value))) {
								sums[index] = values.reduce((prev, curr) => {
									const value = Number(index);

									if (!isNaN(value) && index != 3) {
										return prev + curr;
									} else {
										return '';
									}

								}, 0);
								if (index == 4 || index == 6) {
									sums[index] = sums[index].toFixed(2);
								}
								if (index == 1 || index == 3 || index == 4 || index == 5 || index == 7)
									sums[index] = '---';
								if (index == 6)
									sums[index] += ' 元';
							} else {
								sums[index] = '';
							}
						});
						return sums;
					}
				},
			})

			var apphard = new Vue({
				el: "#apphard",
				data: {
					formLabelWidth: '120px',
					value7: '',
					approvetype:1,
					inputtheme: '',
					activeNames: [],
					radiosatus: [{
						required: true,
						message: '请选择状态',
						trigger: 'change'
					}],
					orderpay: '',
					dialogOrderItem: false,
					dialogFormVisible: false,
					dialogApproveadmin:false,
					dialogApprove:false,
					form: {
						ID: oid,
						otitle: '', //主题
						otype: '', //订单分类
						osign: '', //客户签约人
						osign1: '', //收货人
						name: '',
						region: '',
						date1: new Date(), //创建时间
						date2: '', //最晚发货时间
						delivery: false,
						type: [],
						resource: '',
						radiosatus: '1098', //订单状态
						textcommunication: '',
						finput: '',
						tinput: '',
						uid: '', //所有者
						remark: '', //备注
						orderId: '', //订单编号
						oconsignee: '', //收货人名字
						conphone: '', //收货人电话
						contaddress: '', //收货地址
						postcode: '', //邮编
						customer: '', //客户编号
						orderpay: '', //付款方式
						fire: '',
						get: ''
					},
					rules: {
						otitle: [{
							required: true,
							message: '请输入主题',
							trigger: 'blur'
						}, ],
						customer: [{
								required: true,
								message: '请选择客户',
								trigger: 'blur'
							},
							{
								required: true,
								message: '请选择客户',
								trigger: 'change'
							}
						],
						date1: [{
							required: true,
							message: '请选择创建日期',
							trigger: 'change'
						}],
						date2: [{
							required: true,
							message: '请选择最晚发货日期',
							trigger: 'change'
						}],
						type: [{
							type: 'array',
							required: true,
							message: '请至少选择一个活动性质',
							trigger: 'change'
						}],
						resource: [{
							required: true,
							message: '请选择活动资源',
							trigger: 'change'
						}],
						uosign: [{
								required: true,
								message: '签约人不能为空',
								trigger: 'blur'
							},
							{
								required: true,
								message: '签约人不能为空',
								trigger: 'change'
							}
						],
						uitemv: [{
								required: true,
								message: '所有者不能为空',
								trigger: 'blur'
							},
							{
								required: true,
								message: '所有人不能为空',
								trigger: 'change'
							}
						]
					},

					options: [],
					optionspay: [],
					/* 日期选择 */
					pickerOptions1: {
						disabledDate(time) {
							return time.getTime() > Date.now();
						},
						shortcuts: [{
							text: '今天',
							onClick(picker) {
								picker.$emit('pick', new Date());
							}
						}, {
							text: '昨天',
							onClick(picker) {
								const date = new Date();
								date.setTime(date.getTime() - 3600 * 1000 * 24);
								picker.$emit('pick', date);
							}
						}, {
							text: '一周前',
							onClick(picker) {
								const date = new Date();
								date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
								picker.$emit('pick', date);
							}
						}]
					},
					formLabelWidth: '100px',
					gettoday: new Date(),
					gettime: new Date(),
					prostarttoday: '',
					prosalettoday: '',
					paytoday: '',
					uosign: [],
					uosigns: [],
					osignloading: false,
					uosign1: [],
					uosigns1: [],
					osignloading1: false,
					uitemv: [],
					uitemvs: [],
					uidloading: false,
					cumitemv: [],
					cumitemvs: [],
					cumloading: false,
					contactes: [],
					custIDoptions: [{
						value: '选项1',
						label: '张三'
					}, {
						value: '选项2',
						label: '李四'
					}, {
						value: '选项3',
						label: '王五'
					}, {
						value: '选项4',
						label: '赵二'
					}],
					restaurants: [],
				},
				methods: {
					showorderitem() {
						window.location.href = '/sales/prosale/orderItemView?id=' + oid;
					},
					approveadmin(){
						var _this=this; 
						axios.post("/sales/prosale/orderapprove",
							//参数转换
							Qs.stringify({'id':_this.approvetype,
								'oid':oid
							},
							{arrayFormat: 'brackets'})
							//ajax请求成功的回调函数
						).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v.data.contact);
							window.location.href = '/sales/prosale/orderView?id=' + oid;
						}).catch(function() {
							alert("信息出错了");
						});
					},
					approve(){
						axios.post("/sales/prosale/orderapprove",
							//参数转换
							Qs.stringify({'id':2,
								'oid':oid
							},
							{arrayFormat: 'brackets'})
							//ajax请求成功的回调函数
						).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v.data.contact);
							window.location.href = '/sales/prosale/orderView?id=' + oid;
						}).catch(function() {
							alert("信息出错了");
						});
					},
					
					printOrder() {
						$("#max").jqprint({
							debug: true,
							importCSS: true,
							printContainer: true,
							operaSupport: false,
						});
					},
					updateOrder() {
						var _this = this;
						axios.post("/sales/prosale/updateOrderpage",
							//参数转换
							Qs.stringify({
								'ID': oid
							}, {
								arrayFormat: 'brackets'
							})
							//ajax请求成功的回调函数
						).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v.data.contact);
							//将数据装换成界面显示
							_this.uosigns = v.data.contact.map(item => {
								return {
									value: item.ID,
									label: item.name
								};
							});
							_this.uosign = _this.uosigns;
							_this.uosigns1 = v.data.contact.map(item => {
								return {
									value: item.ID,
									label: item.name
								};
							});

							_this.cumitemvs = v.data.customer.map(item => {
								return {
									value: item.ID,
									label: item.name
								};
							});

							_this.cumitemv = _this.cumitemvs;
							_this.contactes = v.data.contact;
							_this.uitemvs = v.data.userAll.map(item => {
								return {
									value: item.ID,
									label: item.name
								};
							});
							_this.uitemv = _this.uitemvs;
							_this.uosign1 = _this.uosigns1;
							console.log(_this.uitemvs);
							_this.optionspay = v.data.opay;
							_this.options = v.data.otype;
							_this.form.otitle = v.data.orderInfo.theme;
							_this.form.customer = v.data.orderInfo.cust_id;
							_this.form.orderId = v.data.orderInfo.ID;
							_this.form.otype = v.data.orderInfo.type;
							_this.form.orderpay = v.data.orderInfo.pay;
							_this.form.date1 = v.data.orderInfo.statretime;
							_this.form.fire = v.data.orderInfo.fire;
							_this.form.date2 = v.data.orderInfo.o_fadate;
							_this.form.get = v.data.orderInfo.get;
							_this.form.radiosatus = v.data.orderInfo.dstatus;
							v.data.ftype.map(item => {
								if (item.value == v.data.orderInfo.fstutes) {
									_this.form.finput = item.label;
								}
							});
							v.data.ttype.map(item => {
								if (item.value == v.data.orderInfo.salesreturn) {
									_this.form.tinput = item.label;
								}
							});
							_this.form.osign = v.data.orderInfo.o_sign;
							_this.form.uid = v.data.orderInfo.u_id;

							_this.form.textcommunication = v.data.orderInfo.oremark;
							_this.form.oconsignee = v.data.orderInfo.oconsignee;
							_this.form.conphone = v.data.orderInfo.oconphone;
							_this.form.contaddress = v.data.orderInfo.oaddress;
							_this.form.postcode = v.data.orderInfo.opostcode;
							_this.dialogFormVisible = true;


						}).catch(function() {
							alert("信息出错了");
						});
					},
					handleChange(val) {
						console.log(val);
					},
					//这个是列表的选择事件
					handleSelect(item) {
						var contacts = [{
							con: item.label2,
							conlabel: item.conName
						}];
						console.log("item:" + item.conName);
						this.contacts = contacts;
						this.gdID = item.label1;
					},
					loadAll() {
						// alert("dd");
						var _this = this;
						axios.get("/sales/abroadsaleCustName", {
								params: {
									custName: this.customer
								}
							}
							//ajax请求成功的回调函数
						).then(function(response) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(response.data);
							_this.restaurants = response.data;
						}).catch(function() {
							alert("显示客户初始化数据出错了");
						}); //这个是数据的初始化
					},
					//这个是显示查询的数据
					querySearchAsync(queryString, cb) {

						var restaurants = this.restaurants;
						var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;
						// alert( cb);
						clearTimeout(this.timeout);
						this.timeout = setTimeout(() => {
							cb(this.restaurants);
						}, 3000 * Math.random());
						if (queryString == '') {
							this.customer = null;
							this.loadAll();
							var restaurants = this.restaurants;
							var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;
							// alert(cb);
							clearTimeout(this.timeout);
							this.timeout = setTimeout(() => {
								cb(this.restaurants);
							}, 3000 * Math.random());
						}
					},
					//这个是根据输入的内容筛选数据
					createStateFilter(queryString) {
						console.log("queryString2:" + queryString);
						if (queryString != null && queryString != " ") {
							this.customer = queryString;
						} else {
							this.customer = null;
						}
						console.log("customer:" + this.customer);
						// this.$options.methods.mounted();
						//  this.mounted();
						this.loadAll();
						return (state) => {
							return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
						};
					},
					addOrder() {
						var _this = this;
						axios.post("/sales/prosale/addOrderpage",
							//参数转换
							//Qs.stringify(this.form,{arrayFormat: 'brackets'})
							//ajax请求成功的回调函数
						).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v.data.contact);
							//将数据装换成界面显示
							_this.uosigns = v.data.contact.map(item => {
								return {
									value: item.ID,
									label: item.name
								};
							});
							_this.uosign = _this.uosigns;
							_this.uosigns1 = v.data.contact.map(item => {
								return {
									value: item.ID,
									label: item.name
								};
							});
							_this.contactes = v.data.contact;
							_this.uitemvs = v.data.userAll.map(item => {
								return {
									value: item.ID,
									label: item.name
								};
							});
							_this.uitemv = _this.uitemvs;
							_this.uosign1 = _this.uosigns1;
							console.log(_this.uitemvs);
							_this.optionspay = v.data.opay;
							_this.options = v.data.otype;
							_this.dialogFormVisible = true;
						}).catch(function() {
							alert("信息出错了");
						});
					},
					//加载联系人
					osignremoteMethod(query) {
						var _this = this;
						if (query !== '') {
							this.osignloading = true;
							setTimeout(() => {
								this.osignloading = false;
								this.uosign = _this.uosigns.filter(item => {
									return item.label.toLowerCase()
										.indexOf(query.toLowerCase()) > -1;
								});
							}, 200);
						} else {
							this.uosign = [];
						}
					},
					//清除客户签约人
					uosignto() {
						var _this = this;
						_this.uosign = _this.uosigns;
					},
					//加载收货联系人
					osignremoteMethod1(query) {
						var _this = this;
						if (query !== '') {
							this.osignloading1 = true;
							setTimeout(() => {
								this.osignloading1 = false;
								this.uosign1 = _this.uosigns1.filter(item => {
									return item.label.toLowerCase()
										.indexOf(query.toLowerCase()) > -1;
								});
							}, 200);
						} else {
							this.uosign = [];
						}
					},
					//清除客户签约人
					uosign1to() {
						var _this = this;
						_this.uosign1 = _this.uosigns1;
					},
					//加载界面所有者
					uidremoteMethod(query) {
						var _this = this;
						if (query !== '') {
							this.uidloading = true;
							setTimeout(() => {
								this.uidloading = false;
								this.uitemv = _this.uitemvs.filter(item => {
									return item.label.toLowerCase()
										.indexOf(query.toLowerCase()) > -1;
								});
							}, 200);
						} else {
							this.uosign = [];
						}
					},
					uitemvto() {
						var _this = this;
						_this.uitemv = _this.uitemvs;
					},
					//加载界面所有者
					cumremoteMethod(query) {
						var _this = this;
						if (query !== '') {
							this.cumloading = true;
							setTimeout(() => {
								this.cumloading = false;
								this.cumitemv = _this.cumitemvs.filter(item => {
									return item.label.toLowerCase()
										.indexOf(query.toLowerCase()) > -1;
								});
							}, 200);
						} else {
							this.uosign = [];
						}
					},
					cumitemvto() {
						var _this = this;
						_this.cumitemv = _this.cumitemvs;
					},
					//通过联系人加载收货人和收货地址
					aa: function() {
						var _this = this;

						_this.contactes.map(item => {
							if (_this.form.osign1 == item.ID) {
								_this.form.oconsignee = item.name;
								_this.form.conphone = item.phone;
								_this.form.contaddress = item.address;
								_this.form.postcode = item.code;
							}
						});
					},

					//提交添加
					submitFormUp(form) {
						//验证方法
						this.$refs[form].validate((valid) => {
							if (valid) {
								//post提交数据
								axios.post("/sales/prosale/updateorderif",
									//参数转换
									Qs.stringify(
										this.form, {
											arrayFormat: 'brackets'
										})
									//	params:
									//ajax请求成功的回调函数
								).then(function(v) {
									console.log("回调成功，获取了服务器端返回的值v");
									console.log(v);
									window.location.href = '/sales/prosale/orderView?id=' + oid;
								}).catch(function() {
									alert("出错了");
								});
							} else {
								console.log('error submit!!');
								return false;
							}
						});
					},
					//重置表单
					resetForm(formName) {
						this.$refs[form].resetFields();
					}
				},
				mounted:function(){
					if (${orderItemView}.length == 0) {
						this.dialogOrderItem= true;
					}
				}
				
			})

			var Max2 = new Vue({
				el: "#max2",
				data: {
					returngoodpro:[],
					dialogoutgood:false,
					stockremoval: false,
					outgoodgo: true,
					returnPId:'',
					returnCount:'',
					returnre:'',
					numMax:0,
					form:{
						
					},
					returnform:{
						pId:'',
						riPrice:'',
						riCount:'',
						riMoney:'',
						riResult:'',
						
						odDiscount:'',
						pName:'',
						pUnit:'',
					},
					ogid: '${outgood.ogId}',
					tableData: outgooditem,
					tableData1: [],
				},
				methods: {
					deletenew(index, rows) {
						rows.splice(index, 1);
						this.returngoodpro= orderitemView.map(item => {
						    return { value: item.p_id, label: item.p_name,count:item.count };
						  });
						   for(var i=0;i<orderitemView.length;i++ ){
						  	for(var j=0;j<refunlist.length;j++){
								var obj= refunlist[j].listMap;
						  		for(var z=0;z<obj.length;z++){
						  			if(orderitemView[i].p_id==obj[z].pId){
						  				for(var item=0 ; item<this.returngoodpro.length;item++){
											if(this.returngoodpro[item].value==obj[z].pId){
												this.returngoodpro[item].count=this.returngoodpro[item].count-obj[z].riCount;
												if(this.returngoodpro[item].count<=0){
													this.returngoodpro.splice(item,1);
												}
											}
										}
						  			}
						  		}
						  	}
						  }
						   //将两者相同的截取
						  for(var i=0; i<this.returngoodpro.length;i++){
						  	for(var j=0; j< this.tableData1.length;j++){
						  		var item1=this.tableData1[j];
						  		 if(item.value==item1.pId){
						  			item.count= item.count- item1.riCount;
									alert(item.count);
						  			if(item.count<=0){
						  				this.returngoodpro.splice(i,1);
						  			}
						  									
						  		}
						  	}
						  }
					},
					adddispatchBill() {
						var _this = this;
						var params = new URLSearchParams();
						params.append('oid', oid);
						axios.post("/sales/prosale/addoutGoodsview", params).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v);
							window.location.href = '/sales/prosale/outGoodsbill?ogid=' + v.data;
						}).catch(function() {
							alert("出错了");
						});
					},
					appreturngood(){
						var _this = this;
						var sum=0;
						this.tableData1.map(item=>{
							sum+=item.riMoney;
						})
						var params = new URLSearchParams();
						params.append('refaGood',JSON.stringify(this.tableData1));
						params.append('oid', oid);
						params.append('sumMoney', sum);
						axios.post("/sales/prosale/addreturnGoodsview", params).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v);
							window.location.href = '/sales/prosale/orderView?id=' + oid;
						}).catch(function() {
							alert("出错了");
						});
					},
					//退货操作
					returngoodview(){
						this.tableData1=[];
						this.returngoodpro= orderitemView.map(item => {
						    return { value: item.p_id, label: item.p_name,count:item.count };
						  });
						  
						  for(var i=0;i<orderitemView.length;i++ ){
						  	 
						  	for(var j=0;j<refunlist.length;j++){
								var obj= refunlist[j].listMap;
						  		for(var z=0;z<obj.length;z++){
						  			if(orderitemView[i].p_id==obj[z].pId){
						  				for(var item=0 ; item<this.returngoodpro.length;item++){
											
											if(this.returngoodpro[item].value==obj[z].pId){
												this.returngoodpro[item].count=this.returngoodpro[item].count-obj[z].riCount;
												if(this.returngoodpro[item].count<=0){
													this.returngoodpro.splice(item,1);
												}
											}
										}
						  			}
						  		}
						  	}
						  }
						   //将两者相同的截取
						  for(var i=0; i<this.returngoodpro.length;i++){
						  	var item=this.returngoodpro[i];
						  	for(var j=0; j< this.tableData1.length;j++){
						  		var item1=this.tableData1[j];
						  		 if(item.value==item1.pId){
						  			item.count= item.count- item1.riCount;
						  			if(item.count<=0){
						  				this.returngoodpro.splice(i,1);
						  			}
									
						  		}
						  	}
						  }
						  
						this.dialogoutgood=true;
					},
					selectprodut1(){
					orderitemView.map(item => {
					   if(this.returnPId==item.p_id){
						   this.returnform.pId=item.p_id;
						   this.returnform.riPrice=item.price;
						   this.returnform.riCount=item.count;
						   this.returnCount=item.count;
						   this.returnform.riMoney=item.money;
						  // this.returnform.riResult=this.returnre; 
						   this.returnform.odDiscount=item.discount;
						   this.returnform.pName=item.p_name;
						   this.returnform.pUnit=item.p_unit;
					   }
					  });
					  this.returngoodpro.map(item => {
						if(this.returnPId==item.value){
						   this.returnCount=item.count;
						   this.numMax=item.count;
						}
					  });
					  
					},
					returnPush(){
						var zz=0;
						var returnf={
							pId:this.returnform.pId,
							riPrice: this.returnform.riPrice,
							riCount:this.returnCount,
							riMoney:this.returnform.riPrice*this.returnCount,
							riResult:this.returnre,
							odDiscount:  this.returnform.odDiscount,
							pName:this.returnform.pName,
							pUnit: this.returnform.pUnit,
						};
						this.returnform.riCount=this.returnCount;
						this.returnform.riResult=this.returnre; 
						console.log("haha"+this.tableData1);
						this.tableData1.map(x => {
								console.log("x"+JSON.stringify(x));
								 if(x.pId==this.returnform.pId){
									x.riCount= parseInt(this.returnCount)+ parseInt(x.riCount);
									x.riMoney=x.riCount*x.riPrice;
									zz=1;
								}
						});
						if(this.returnform.pId!="" && this.returnPId!=""&& zz==0){
							 this.tableData1.push(returnf);
						}
						//将两者相同的截取
						for(var i=0; i<this.returngoodpro.length;i++){
							var item=this.returngoodpro[i];
							for(var j=0; j< this.tableData1.length;j++){
								var item1=this.tableData1[j];
								 if(item.value==item1.pId){
									 item.count= item.count- item1.riCount;
									 if(item.count==0){
										 	this.returngoodpro.splice(i,1);
									 }
									/* orderitemView.map(item2 => {
										if(item1.pId==item2.p_id)
										   if(item2.count==item1.riCount){
										   	this.returngoodpro.splice(i,1);
										   }
									   });
									item.count= item.count- item1.riCount; */
									this.tableData1=this.tableData1.map(x => {
										if(x.value==item1.pId){
											return { value: x.value, label: x.label,count:item.count};
										}
										return x;
									});
								}
							}
						}
						/* this.returngoodpro= this.returngoodpro.map(item => {
							var xx=0;
								console.log("看看"+item);
								 this.tableData1.map(item1 => {
									 console.log("所示" +item1);
									 if(item.value==item1.pId){
										 alert(456);
										if(item.count<=item1.riCount){
											xx=1;
										}
									}
								});
								return item;
						  }); */
						 console.log(this.returngoodpro);
						this.returnform=[];
						this.returnCount='';
						this.returnre='';
						this.returnPId='';
					},
					outgoodview() {
						if (this.ogid == null || this.ogid != '')
							window.location.href = '/sales/prosale/outGoodsbill?ogid=' + this.ogid;
					},
					getSummaries(param) {
						const {
							columns,
							data
						} = param;
						const sums = [];
						columns.forEach((column, index) => {
							if (index === 0) {
								sums[index] = '总计';
								return;
							}
							const values = data.map(item => Number(item[column.property]));

							if (!values.every(value => isNaN(value))) {
								sums[index] = values.reduce((prev, curr) => {
									const value = Number(index);

									if (!isNaN(value) && index != 3) {
										return prev + curr;
									} else {
										return '';
									}

								}, 0);
								if (index == 4 || index == 6) {
									sums[index] = sums[index].toFixed(2);
								}
								if (index == 1 || index == 3 || index == 4 || index == 5 || index == 7)
									sums[index] = '---';
								if (index == 6)
									sums[index] += ' 元';
							} else {
								sums[index] = '';
							}
						});
						return sums;
					}

				},
				mounted: function() {
					if (${
							outgoodCount
						} == 0) {
						this.stockremoval = true;
						this.outgoodgo = false;
					}
				}
			})
			
			var Max3=new Vue({
					el: "#max3",
					data: {
						outgoodgo:Max2.outgoodgo,
						refunlist1:refunlist,
					},
					methods:{
							getSummaries(param) {
								const {
									columns,
									data
								} = param;
								const sums = [];
								columns.forEach((column, index) => {
									if (index === 0) {
										sums[index] = '总计';
										return;
									}
									const values = data.map(item => Number(item[column.property]));
						
									if (!values.every(value => isNaN(value))) {
										sums[index] = values.reduce((prev, curr) => {
											const value = Number(index);
						
											if (!isNaN(value) && index != 3) {
												return prev + curr;
											} else {
												return '';
											}
						
										}, 0);
										if (index == 4 || index == 5) {
											sums[index] = sums[index].toFixed(2);
										}
										if (index == 1 || index == 3 || index == 4  || index == 6)
											sums[index] = '---';
										if (index == 5)
											sums[index] += ' 元';
									} else {
										sums[index] = '';
									}
								});
								return sums;
							},
							refundgoods(id){
								window.location.href = '/sales/prosale/refundgoodview?rgid=' + id;
							}
					},
				});
			
			var appreturn = new Vue({
				el: "#appreturn",
				data: {
					pickerOptions0: {
						disabledDate(time) {
							return time.getTime() < Date.now() - 8.64e7;
						}
					},
					bmp: bmp,
					rm: rm,
					osumMoney: ${
						orderView.fire
					},
					bsumMoney: '',
					addbmpboo: false,
					bsumMoney1: '',
					ztableData: [],
					dialogbmpviewVisible: false,
					dialogOrderItem: false,
					rdialogFormVisible: false,
					formLabelWidth: '120px',
					formLabelWidth1: '100px',
					comcustid: '',
					zbmpform: {
						comcustid: '',
						orderid: '',
						date1: '',
						bmpmoney: '',
						radiosatus: '',
						percent: '',
						uid: '',
						textcommunication: ''
					},
					bmpform: {
						comcustid: '',
						orderid: '',
						date1: '',
						bmpmoney: '',
						radiosatus: '',
						uid: '',
						textcommunication: ''
					},
					comcustid: '',
					options: [],
					optionspay: [],
					rmform: {
						ID: '',
						comcustid: '',
						orderid: '',
						date1: '',
						rmmoney: '',
						rmpay: '',
						uid: ${user.uId},
						rmsort: '',
						rmremark: ''
					},
					dialogFormVisible: false,
					rules: {
						comcustid: [{
							required: true,
							message: '请选择客户',
							trigger: 'change'
						}, ],
						orderid: [{
							required: true,
							message: '请选择订单',
							trigger: 'change'
						}, ],
						bmpmoney: [{
							required: true,
							message: '总金额不能为空',
							trigger: 'blur'
						}, ],
						isBackMoney: [{
							required: true,
							message: '请选择回款状态',
							trigger: 'change'
						}, ],
						uid: [{
							required: true,
							message: '所有人不能为空',
							trigger: 'change'
						}, ],
						date1: [{
							required: true,
							message: '请选择计划回款日期',
							trigger: 'change'
						}],
					},
					customers: [],
					customer: [],
					cumloading: false,
					ordere: [],
					orderes: [],
					orloading: false,
					uitemv: [],
					uitemvs: [],
					uidloading: false,
					disabledInput: false
				},
				methods: {
					//弹出框新建订单明细
					showorderitem() {

						window.location.href = '/sales/prosale/orderItemView?id=' + oid;
					},
					backmp(id, bmpdate, bmpmoney) {
						this.disabledInput = true;
						var _this = this;
						axios.post("/sales/prosale/addrmpage",
							//参数转换
							//Qs.stringify(this.form,{arrayFormat: 'brackets'})
							//ajax请求成功的回调函数
						).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v.data);
							//将数据装换成界面显示
							//客户信息
							_this.customers = v.data.customer.map(item => {
								return {
									value: item.ID,
									label: item.name
								};
							});
							_this.customer = _this.customers;
							/* _this.uosigns1= v.data.contact.map(item => {
								return { value: item.ID, label: item.name };
							}); */
							/* _this.contactes=v.data.contact; */
							//所有者信息
							_this.uitemvs = v.data.userAll.map(item => {
								return {
									value: item.ID,
									label: item.name
								};
							});
							_this.uitemv = _this.uitemvs;
							//付款方式信息
							_this.options = v.data.sort;
							//分类信息
							_this.optionspay = v.data.pay;
							console.log(_this.uitemvs);
							_this.rmform.comcustid = orderinfo.cust_id;
							_this.rmform.orderid = orderinfo.ID;
							_this.rmform.date1 = bmpdate;
							_this.rmform.ID = id;
							_this.rmform.rmmoney = bmpmoney;
							_this.orderes = [{
								value: orderinfo.ID,
								label: orderinfo.theme
							}];
							/* _this.optionspay=v.data.opay;
							_this.options=v.data.otype; */
							_this.rdialogFormVisible = true;
						}).catch(function() {
							alert("信息出错了");
						});
					},
					loadAll() {
						return [];
					},
					addrmpage() {
						this.disabledInput = false;
						var _this = this;
						axios.post("/sales/prosale/addrmpage",
							//参数转换
							//Qs.stringify(this.form,{arrayFormat: 'brackets'})
							//ajax请求成功的回调函数
						).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v.data);
							//将数据装换成界面显示
							//客户信息
							_this.customers = v.data.customer.map(item => {
								return {
									value: item.ID,
									label: item.name
								};
							});
							_this.customer = _this.customers;
							/* _this.uosigns1= v.data.contact.map(item => {
								return { value: item.ID, label: item.name };
							}); */
							/* _this.contactes=v.data.contact; */
							//所有者信息
							_this.uitemvs = v.data.userAll.map(item => {
								return {
									value: item.ID,
									label: item.name
								};
							});
							_this.uitemv = _this.uitemvs;
							//付款方式信息
							_this.options = v.data.sort;
							//分类信息
							_this.optionspay = v.data.pay;
							console.log(_this.uitemvs);
							_this.rmform.comcustid = orderinfo.cust_id;
							_this.rmform.orderid = orderinfo.ID;
							_this.rmform.ID = 0;
							_this.rmform.rmmoney = '';
							_this.orderes = [{
								value: orderinfo.ID,
								label: orderinfo.theme
							}];
							/* _this.optionspay=v.data.opay;
							_this.options=v.data.otype; */
							_this.rdialogFormVisible = true;
						}).catch(function() {
							alert("信息出错了");
						});
					},
					addbmppage() {
						var _this = this;
						axios.post("/sales/prosale/addbmppage",
							//参数转换
							//Qs.stringify(this.form,{arrayFormat: 'brackets'})
							//ajax请求成功的回调函数
						).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v.data);
							//将数据装换成界面显示
							_this.customers = v.data.customer.map(item => {
								return {
									value: item.ID,
									label: item.name
								};
							});
							_this.customer = _this.customers;
							/* _this.uosigns1= v.data.contact.map(item => {
								return { value: item.ID, label: item.name };
							}); */
							/* _this.contactes=v.data.contact; */
							_this.uitemvs = v.data.userAll.map(item => {
								return {
									value: item.ID,
									label: item.name
								};
							});
							_this.uitemv = _this.uitemvs;
							console.log(_this.uitemvs);
							/* _this.optionspay=v.data.opay;
							_this.options=v.data.otype; */
							_this.bmpform.comcustid = orderinfo.cust_id;
							_this.bmpform.orderid = orderinfo.ID;
							_this.orderes = [{
								value: orderinfo.ID,
								label: orderinfo.theme
							}];
							_this.dialogbmpviewVisible = true;

						}).catch(function() {
							alert("信息出错了");
						});
					},

					querySearchAsync(queryString, cb) {
						var restaurants = this.restaurants;
						var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;
						clearTimeout(this.timeout);
						this.timeout = setTimeout(() => {
							cb(results);
						}, 3000 * Math.random());
					},
					//加载界面客户
					orremoteMethod(query) {
						var _this = this;
						if (query !== '') {
							this.orloading = true;
							setTimeout(() => {
								this.orloading = false;
								this.ordere = _this.orderes.filter(item => {
									return item.label.toLowerCase()
										.indexOf(query.toLowerCase()) > -1;
								});
							}, 200);
						} else {
							this.orloading = true;
							setTimeout(() => {
								this.orloading = false;
								this.ordere = _this.orderes.filter(item => {
									return item.label;
									/* return item.label.toLowerCase()
									   .indexOf(query.toLowerCase()) > -1; */
								});
							}, 200);
						}
					},
					comcustidto() {

						var _this = this;
						_this.customer = _this.customers;
					},
					uitemvto() {
						var _this = this;
						_this.uitemv = _this.uitemvs;
					},
					selectOne() {
						var _this = this;
						axios.post("/sales/prosale/bmporderpage",
							Qs.stringify({
								'ID': _this.bmpform.comcustid
							}, {
								arrayFormat: 'brackets'
							})
						).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v.data);
							_this.bmpform.orderid = ' ';
							_this.orderes = v.data.order.map(item => {
								return {
									value: item.ID,
									label: item.theme
								};
							});
							//_this.orderes
						}).catch(function() {
							alert("信息出错了");
						});
					},
					//加载界面客户
					cumremoteMethod(query) {
						var _this = this;
						if (query !== '') {
							this.cumloading = true;
							setTimeout(() => {
								this.cumloading = false;
								this.customer = _this.customers.filter(item => {
									return item.label.toLowerCase()
										.indexOf(query.toLowerCase()) > -1;
								});
							}, 200);
						} else {
							this.uosign = [];
						}
					},

					//加载界面所有者
					uidremoteMethod(query) {
						var _this = this;
						if (query !== '') {
							this.uidloading = true;
							setTimeout(() => {
								this.uidloading = false;
								this.uitemv = _this.uitemvs.filter(item => {
									return item.label.toLowerCase()
										.indexOf(query.toLowerCase()) > -1;
								});
							}, 200);
						} else {
							this.uosign = [];
						}
					},
					createStateFilter(queryString) {
						return (state) => {
							return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
						};
					},
					handleSelect(item) {
						console.log(item);
					},
					mounted() {
						this.restaurants = this.loadAll();
					},
					submitForm(formName) {
						this.$refs[formName].validate((valid) => {
							if (valid) {
								//post提交数据
								axios.post("/sales/prosale/addbmp",
									//参数转换
									Qs.stringify(
										this.bmpform, {
											arrayFormat: 'brackets'
										})
									//	params:
									//ajax请求成功的回调函数
								).then(function(v) {
									console.log("回调成功，获取了服务器端返回的值v");
									console.log(v);
									window.location.href = '/sales/prosale/orderView?id=' + oid;
								}).catch(function() {
									alert("出错了");
								});
							} else {
								console.log('error submit!!');
								return false;
							}
						});
					},
					rsubmitForm(rmform) {
						this.$refs[rmform].validate((valid) => {
							if (valid) {
								//post提交数据
								axios.post("/sales/prosale/addrm",
									//参数转换
									Qs.stringify(
										this.rmform, {
											arrayFormat: 'brackets'
										})
									//	params:
									//ajax请求成功的回调函数
								).then(function(v) {
									console.log("回调成功，获取了服务器端返回的值v");
									console.log(v);
									window.location.href = '/sales/prosale/orderView?id=' + oid;
								}).catch(function() {
									alert("出错了");
								});
							} else {
								console.log('error submit!!');
								return false;
							}
						});
					},
					resetForm(formName) {
						this.$refs[formName].resetFields();
					},
					//验证金额是否合法
					updatebmpmoney(row) {
						var tableData2 = {
							comcustid: '',
							orderid: '',
							date1: '',
							bmpmoney: '',
							radiosatus: '',
							percent: '',
							uid: '',
							textcommunication: ''
						};
						var sumMoney = 0;
						var x = 0;
						var zbmplist = [];
						var v = /^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$/;
						if (v.test(row.bmpmoney)) {
							tableData2.comcustid = this.zbmpform.comcustid;
							tableData2.orderid = this.zbmpform.orderid;
							tableData2.uid = this.zbmpform.uid;
							for (let item of this.ztableData) {
								var sumbmp = parseFloat(sumMoney);
								sumMoney = parseFloat(sumMoney) + parseFloat(item.bmpmoney);
								item.percent = item.bmpmoney / this.bsumMoney1 * 100;
								if (sumMoney <= this.bsumMoney1) {
									zbmplist.push(item);
								} else {
									x++;
								}
								if (sumMoney > this.bsumMoney1 && sumMoney != this.bsumMoney1) {
									//sumMoney = parseFloat(sumMoney)+ parseFloat(item.bmpmoney) ;
									item.bmpmoney = this.bsumMoney1 - sumbmp;
									item.percent = item.bmpmoney / this.bsumMoney1 * 100;
									zbmplist.push(item);
								}
							}
							if (x > 0) {
								this.ztableData = zbmplist;
							} else {
								tableData2.bmpmoney = this.bsumMoney1 - sumMoney;
								tableData2.percent = tableData2.bmpmoney / this.bsumMoney1 * 100;
								this.ztableData.push(tableData2);
							}
							var k = [];
							for (let item of this.ztableData) {
								if (item.bmpmoney > 0) {
									k.push(item);
								}
							}
							this.ztableData = k;
						} else {
							row.bmpmoney = this.bsumMoney1;
						}
						/* 	var disc = row.price / row.price1;
							row.discount = disc.toFixed(2);
							var sumMoney = row.price * row.count;
							row.money = sumMoney; */
					},
					updatepercent(row) {
						var tableData2 = {
							comcustid: '',
							orderid: '',
							date1: '',
							bmpmoney: '',
							radiosatus: '',
							percent: '',
							uid: '',
							textcommunication: ''
						};
						var sumPercent = 0;
						var x = 0;
						var zbmplist = [];
						var v = /^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$/;
						if (v.test(row.percent)) {
							tableData2.comcustid = this.zbmpform.comcustid;
							tableData2.orderid = this.zbmpform.orderid;
							tableData2.uid = this.zbmpform.uid;
							for (let item of this.ztableData) {
								var sumbmp = parseFloat(sumPercent);
								sumPercent = parseFloat(sumbmp) + parseFloat(item.percent);
								item.bmpmoney = item.percent * this.bsumMoney1 / 100;
								if (sumPercent <= 100) {
									zbmplist.push(item);
								} else {
									x++;
								}
								if (sumPercent > 100 && sumPercent != 100) {
									//sumMoney = parseFloat(sumMoney)+ parseFloat(item.bmpmoney) ;
									item.percent = 100 - sumbmp;
									item.bmpmoney = item.percent * this.bsumMoney1 / 100;
									zbmplist.push(item);
								}
							}
							if (x > 0) {
								this.ztableData = zbmplist;
							} else {
								tableData2.percent = 100 - sumPercent;
								tableData2.bmpmoney = tableData2.percent * this.bsumMoney1 / 100;
								this.ztableData.push(tableData2);
							}
							var k = [];
							for (let item of this.ztableData) {
								if (item.bmpmoney > 0) {
									k.push(item);
								}
							}
							this.ztableData = k;
						} else {}
						/* 	var disc = row.price / row.price1;
							row.discount = disc.toFixed(2);
							var sumMoney = row.price * row.count;
							row.money = sumMoney; */
					},
					addrsubmitForm() {
						var _this = this;
						var params = new URLSearchParams();
						console.log(this.ztableData);
						params.append('bmpitem', JSON.stringify(this.ztableData));
						axios.post("/sales/prosale/addbmpitemview", params).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v);
							window.location.href = '/sales/prosale/orderView?id=' + ${
								orderView.ID
							};
						}).catch(function() {
							alert("出错了");
						});
					}
				},
				filters: {
					rounding(value) {
						return value.toFixed(2)
					}
				},
				mounted: function() {
					var _this = this;
					var tableData2 = {
						comcustid: '',
						orderid: '',
						date1: '',
						bmpmoney: '',
						radiosatus: '',
						percent: 100,
						uid: '',
						textcommunication: ''
					};
					var bmpsum = 0;

					for (let bmp1 of bmp) {
						bmpsum += bmp1.bmpmoney;
					}
					this.bsumMoney = bmpsum;
					this.bsumMoney1 = this.osumMoney - this.bsumMoney;
					
					if (this.bsumMoney1 > 0 && ${
							orderItemView
						}.length != 0 && ${orderView.approve}==1) {
						this.addbmpboo = true;
						this.dialogbmpviewVisible = true;
						axios.post("/sales/prosale/addbmppage",
							//参数转换
							//Qs.stringify(this.form,{arrayFormat: 'brackets'})
							//ajax请求成功的回调函数
						).then(function(v) {
							console.log("回调成功，获取了服务器端返回的值v");
							console.log(v.data);
							//将数据装换成界面显示
							_this.customers = v.data.customer.map(item => {
								return {
									value: item.ID,
									label: item.name
								};
							});
							_this.customer = _this.customers;
							_this.uitemvs = v.data.userAll.map(item => {
								return {
									value: item.ID,
									label: item.name
								};
							});
							_this.uitemv = _this.uitemvs;
							_this.zbmpform.comcustid = orderinfo.cust_id;
							_this.zbmpform.orderid = orderinfo.ID;
							_this.zbmpform.uid = ${
								user.uId
							};
							tableData2.comcustid = orderinfo.cust_id;
							tableData2.orderid = orderinfo.ID;
							tableData2.uid = orderinfo.ID;
							_this.orderes = [{
								value: orderinfo.ID,
								label: orderinfo.theme
							}];
						}).catch(function() {
							alert("信息出错了");
						});

						tableData2.textcommunication = this.zbmpform.textcommunication;
						tableData2.bmpmoney = this.bsumMoney1;
						console.log("table");
						console.log(tableData2);
						this.ztableData.push(tableData2);
						console.log("看看");
						console.log(this.ztableData);
					}
					
					if (${orderItemView}.length == 0) {
						this.dialogOrderItem= true;
					}
				},
			})
		
		
		</script>
	</body>
</html>
